﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


namespace FSC.HaNamAPApplication
{
    public partial class Master : System.Web.UI.UserControl
    {
        private string m_controlToLoad = string.Empty;

        public string CurrentUrlWithoutParam {
            get
            {
                return Controler.UrlWithoutParam(Request.RawUrl);
            }
        }

        private void ReadQueryString()
        {
            if (Request.QueryString["page"] != null)
            {
                switch (Request.QueryString["page"].ToLower())
                {
                    case "home":
                        m_controlToLoad = "HNAP_Home.ascx"; break;
                    case "adminoffices":
                        m_controlToLoad = "HNAP_AdminOffices.ascx"; break;
                    case "adminofficesedit":
                        m_controlToLoad = "HNAP_AdminOfficesEdit.ascx"; break;
                    case "adminfields":
                        m_controlToLoad = "HNAP_AdminFields.ascx"; break;
                    case "adminfieldsedit":
                        m_controlToLoad = "HNAP_AdminFieldsEdit.ascx"; break;
                    case "admindoctype":
                        m_controlToLoad = "HNAP_AdminDocType.ascx"; break;
                    case "admindoctypedit":
                        m_controlToLoad = "HNAP_AdminDocTypeEdit.ascx"; break;
                    case "admin":
                        m_controlToLoad = "HNAP_Admin.ascx"; break;
                    case "adminap":
                        m_controlToLoad = "HNAP_AdminAP.ascx"; break;
                    case "adminapedit":
                        m_controlToLoad = "HNAP_AdminAPEdit.ascx"; break;
                    case "adminapreceice":
                        m_controlToLoad = "HNAP_AdminAPReceice.ascx"; break;
                    case "adminapreturnresult":
                        m_controlToLoad = "HNAP_AdminAPReturnResult.ascx"; break;
                    case "admindoc":
                        m_controlToLoad = "HNAP_AdminDoc.ascx"; break;
                    case "admindocedit":
                        m_controlToLoad = "HNAP_AdminDocEdit.ascx"; break;
                    case "ap":
                        m_controlToLoad = "HNAP_AP.ascx"; break;
                    case "apdetail":
                        m_controlToLoad = "HNAP_APDetail.ascx"; break;
                    case "apresult":
                        m_controlToLoad = "HNAP_AdminAPResult.ascx"; break;
                    case "apreport":
                        m_controlToLoad = "HNAP_APReport.ascx"; break;
                    case "news":
                        m_controlToLoad = "HNAP_News.ascx"; break;
                    case "newsdetail":
                        m_controlToLoad = "HNAP_NewsDetail.ascx"; break;
                    case "doc":
                        m_controlToLoad = "HNAP_Doc.ascx"; break;
                    case "docdetail":
                        m_controlToLoad = "HNAP_DocDetail.ascx"; break;
                    case "question":
                        m_controlToLoad = "HNAP_Question.ascx"; break;
                    case "globalcomment":
                        m_controlToLoad = "HNAP_GlobalComment.ascx"; break;
                    case "recommendations":
                        m_controlToLoad = "HNAP_Recommendations.ascx"; break;
                    default:
                        m_controlToLoad = "HNAP_Home.ascx"; break;
                }
            }
            else
            {
                m_controlToLoad = "HNAP_Home.ascx";
            }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            ReadQueryString();

            Control ctl = (Control)this.LoadControl(m_controlToLoad);
            if (ctl != null)
                plBody.Controls.Add(ctl);
        }
    }
}